#include "common.h"

//server
void main()
{
	//waiting for messages  from clients
	while(1)
	{
		//1.receive message 
	 	struct	Msg m1;
		memset(&m1,0,sizeof(m1));        //set 0 into msg
		
		key_t key = ftok(".",200);
		if(key == -1)
			perror("ftok") , exit(-1);
		int msgid = msgget(key, IPC_CREAT | IPC_EXCL);
		if(msgid == -1)
	        	perror("msgget") , exit(-1);
		int res = msgrcv(msgid, &m1 , sizeof(m1) , 0 , 0);
		if(res == -1)
			perror("msgrcv") , exit(-1);
		
		//
		switch(m1.mtype)
		{
			case 1:
				establishAccount(m1);
				break;
			case 2:
				break;
			defalut:
				break;
		}
		
				
		
	}


}
